package me.bincker.formwork.web.test

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import me.bincker.formwork.web.utils.SpringUtils

object TestUtils {

    /**
     * 序列化
     */
    fun serialiseJson(obj: Any): String = SpringUtils.getBean(ObjectMapper::class).writeValueAsString(obj)!!

    /**
     * 反序列化
     */
    inline fun <reified T> deSerialiseJson(json: String): T = SpringUtils.getBean(ObjectMapper::class).readValue(json)
}